home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10924 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  977 b 

  1. Path: news.nchu.edu.tw!news
  2. From: bhughes@tscnet.com (Brian L. Hughes)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Major problem with strings.
  5. Date: 11 Mar 1996 06:50:29 GMT
  6. Organization: Home
  7. Message-ID: <4i0ifl$kr8@news.nchu.edu.tw>
  8. References: <31438275.72DB@aol2.com>
  9. NNTP-Posting-Host: ip215.tscnet.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. In article <31438275.72DB@aol2.com>, neil@aol2.com says...
  15. >
  16. >Here's my code:
  17. >
  18. >1       char *club="";
  19. >2       club="/public_html/neil";
  20. >
  21. >3       strcat(club,argv[1]+5);
  22. >
  23. >4       strcat(club,"/");
  24. >
  25.  
  26. club is defined as a pointer pointing to a constanst in memory.
  27. If you concatenate characters to the constant area you'll be wiping out 
  28. something else.
  29.  
  30.   try
  31.  
  32.    char club[100];
  33.    
  34.    strcpy(club,"/public_html/neil";
  35.    strcat(club, argv[1]+5);;
  36.    strcat(club, "/");
  37.  
  38.  
  39.  
  40.   or
  41.   
  42.    CString club="/public_html/neil";
  43.    club+=argv[1]+5;
  44.    club+="/";
  45.  
  46.   or even less lines...
  47.  
  48.